<?php
$command = isset($_POST['command'])?$_POST['command']:"none";
$url = url('admin','users-manager');
if(isset($_POST['btSubmit'])) {
    unset($_POST['btSubmit']);
    unset($_POST['command']);
    
    if($command == "none"){
        header("location: {$url}");
        exit(0);
    }
    
    if($command == "add"){
        $url = url('admin','users-add');
        header("location: {$url}");
        exit(0);
    }
    /**
     * Lấy dữ liệu từ form
     */
    $data = array();
    foreach($_POST as $id=>$status){
        if($status == "on"){
            $data[] = $id;
        }
    }
    
    /**
     * Xóa item đã check
     */
    if($command == "delete"){
        foreach($data as $id){
            $Bus->User->deleteItemWithId($id);
        }
        $url = url('admin','users-manager');
        header("location: {$url}");
        exit(0);
    }
}
